/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ships.core.icc_;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.StringTokenizer;
import ships.core.ColorSpace;

/**
 *
 * @author fqhuy
 */
public class ICC_Profile {

    private static final long serialVersionUID = -3938515861990936766L;

    public static ICC_Profile getInstance(int CS_sRGB) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private static byte[] getData(long profileID, int icSigHead) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    ICC_Profile(long ID) {
        //super(ID);
    }

    float[] getMediaWhitePoint() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    float[] getXYZTag(int theTagSignature) {
        byte[] theData;
        float[] theXYZNumber;
        int i1, i2, theS15Fixed16;

        theData = getData(theTagSignature); /* get the tag data */
        /* getData will activate deferred
        profiles if necessary */

        theXYZNumber = new float[3];        /* array to return */

        /* convert s15Fixed16Number to float */
        for (i1 = 0, i2 = icXYZNumberX; i1 < 3; i1++, i2 += 4) {
            theS15Fixed16 = intFromBigEndian(theData, i2);
            theXYZNumber[i1] = ((float) theS15Fixed16) / 65536.0f;
        }
        return theXYZNumber;
    }

    protected byte[] getData(int theTagSignature) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    float getGamma(int theSignature) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    short[] getTRC(int theSignature) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    static int getColorSpaceType(long profileID) {
        byte[] theHeader;
        int theColorSpaceSig, theColorSpace;

        theHeader = getData(profileID, icSigHead);
        theColorSpaceSig = intFromBigEndian(theHeader, icHdrColorSpace);
        theColorSpace = iccCStoJCS(theColorSpaceSig);
        return theColorSpace;
    }

    static int intFromBigEndian(byte[] array, int index) {
        return (((array[index] & 0xff) << 24)
                | ((array[index + 1] & 0xff) << 16)
                | ((array[index + 2] & 0xff) << 8)
                | (array[index + 3] & 0xff));
    }

    static void intToBigEndian(int value, byte[] array, int index) {
        array[index] = (byte) (value >> 24);
        array[index + 1] = (byte) (value >> 16);
        array[index + 2] = (byte) (value >> 8);
        array[index + 3] = (byte) (value);
    }

    static short shortFromBigEndian(byte[] array, int index) {
        return (short) (((array[index] & 0xff) << 8)
                | (array[index + 1] & 0xff));
    }

    static void shortToBigEndian(short value, byte[] array, int index) {
        array[index] = (byte) (value >> 8);
        array[index + 1] = (byte) (value);
    }

    static int iccCStoJCS(int theColorSpaceSig) {
        int theColorSpace;

        switch (theColorSpaceSig) {
            case icSigXYZData:
                theColorSpace = ColorSpace.TYPE_XYZ;
                break;

            case icSigLabData:
                theColorSpace = ColorSpace.TYPE_Lab;
                break;

            case icSigLuvData:
                theColorSpace = ColorSpace.TYPE_Luv;
                break;

            case icSigYCbCrData:
                theColorSpace = ColorSpace.TYPE_YCbCr;
                break;

            case icSigYxyData:
                theColorSpace = ColorSpace.TYPE_Yxy;
                break;

            case icSigRgbData:
                theColorSpace = ColorSpace.TYPE_RGB;
                break;

            case icSigGrayData:
                theColorSpace = ColorSpace.TYPE_GRAY;
                break;

            case icSigHsvData:
                theColorSpace = ColorSpace.TYPE_HSV;
                break;

            case icSigHlsData:
                theColorSpace = ColorSpace.TYPE_HLS;
                break;

            case icSigCmykData:
                theColorSpace = ColorSpace.TYPE_CMYK;
                break;

            case icSigCmyData:
                theColorSpace = ColorSpace.TYPE_CMY;
                break;

            case icSigSpace2CLR:
                theColorSpace = ColorSpace.TYPE_2CLR;
                break;

            case icSigSpace3CLR:
                theColorSpace = ColorSpace.TYPE_3CLR;
                break;

            case icSigSpace4CLR:
                theColorSpace = ColorSpace.TYPE_4CLR;
                break;

            case icSigSpace5CLR:
                theColorSpace = ColorSpace.TYPE_5CLR;
                break;

            case icSigSpace6CLR:
                theColorSpace = ColorSpace.TYPE_6CLR;
                break;

            case icSigSpace7CLR:
                theColorSpace = ColorSpace.TYPE_7CLR;
                break;

            case icSigSpace8CLR:
                theColorSpace = ColorSpace.TYPE_8CLR;
                break;

            case icSigSpace9CLR:
                theColorSpace = ColorSpace.TYPE_9CLR;
                break;

            case icSigSpaceACLR:
                theColorSpace = ColorSpace.TYPE_ACLR;
                break;

            case icSigSpaceBCLR:
                theColorSpace = ColorSpace.TYPE_BCLR;
                break;

            case icSigSpaceCCLR:
                theColorSpace = ColorSpace.TYPE_CCLR;
                break;

            case icSigSpaceDCLR:
                theColorSpace = ColorSpace.TYPE_DCLR;
                break;

            case icSigSpaceECLR:
                theColorSpace = ColorSpace.TYPE_ECLR;
                break;

            case icSigSpaceFCLR:
                theColorSpace = ColorSpace.TYPE_FCLR;
                break;

            default:
                throw new IllegalArgumentException("Unknown color space");
        }

        return theColorSpace;
    }

    private static File getProfileFile(String fileName) {
        String path, dir, fullPath;

        File f = new File(fileName); /* try absolute file name */
        if (f.isAbsolute()) {
            /* Rest of code has little sense for an absolute pathname,
            so return here. */
            return f.isFile() ? f : null;
        }
        if ((!f.isFile())
                && ((path = System.getProperty("java.iccprofile.path")) != null)) {
            /* try relative to java.iccprofile.path */
            StringTokenizer st =
                    new StringTokenizer(path, File.pathSeparator);
            while (st.hasMoreTokens() && ((f == null) || (!f.isFile()))) {
                dir = st.nextToken();
                fullPath = dir + File.separatorChar + fileName;
                f = new File(fullPath);
                if (!isChildOf(f, dir)) {
                    f = null;
                }
            }
        }

        if (((f == null) || (!f.isFile()))
                && ((path = System.getProperty("java.class.path")) != null)) {
            /* try relative to java.class.path */
            StringTokenizer st =
                    new StringTokenizer(path, File.pathSeparator);
            while (st.hasMoreTokens() && ((f == null) || (!f.isFile()))) {
                dir = st.nextToken();
                fullPath = dir + File.separatorChar + fileName;
                f = new File(fullPath);
                if (!isChildOf(f, dir)) {
                    f = null;
                }
            }
        }
        if ((f == null) || (!f.isFile())) {
            /* try the directory of built-in profiles */
            f = getStandardProfileFile(fileName);
        }
        if (f != null && f.isFile()) {
            return f;
        }
        return null;
    }

    private static File getStandardProfileFile(String fileName) {
        String dir = System.getProperty("java.home")
                + File.separatorChar + "lib" + File.separatorChar + "cmm";
        String fullPath = dir + File.separatorChar + fileName;
        File f = new File(fullPath);
        if (!f.isFile()) {
            //make sure file was installed in the kernel mode
            try {
                //kernel uses platform independent paths =>
                //   should not use platform separator char
                sun.jkernel.DownloadManager.downloadFile("lib/cmm/" + fileName);
            } catch (IOException ioe) {
            }
        }
        return (f.isFile() && isChildOf(f, dir)) ? f : null;
    }

    private static boolean isChildOf(File f, String dirName) {
        try {
            File dir = new File(dirName);
            String canonicalDirName = dir.getCanonicalPath();
            if (!canonicalDirName.endsWith(File.separator)) {
                canonicalDirName += File.separator;
            }
            String canonicalFileName = f.getCanonicalPath();
            return canonicalFileName.startsWith(canonicalDirName);
        } catch (IOException e) {
            /* we do not expect the IOException here, because invocation
             * of this function is always preceeded by isFile() call.
             */
            return false;
        }
    }

    public static ICC_Profile getInstance(String fileName) throws IOException {
        ICC_Profile thisProfile;
        FileInputStream fis = null;


        File f = getProfileFile(fileName);
        if (f != null) {
            fis = new FileInputStream(f);
        }
        if (fis == null) {
            throw new IOException("Cannot open file " + fileName);
        }

        thisProfile = getInstance(fis);

        fis.close();    /* close the file */

        return thisProfile;
    }

    public static ICC_Profile getInstance(InputStream s) throws IOException {
        byte profileData[];

        //if (s instanceof ProfileDeferralInfo) {
            /* hack to detect profiles whose loading can be deferred */
        //    return getDeferredInstance((ProfileDeferralInfo) s);
        //}

        if ((profileData = getProfileDataFromStream(s)) == null) {
            throw new IllegalArgumentException("Invalid ICC Profile Data");
        }

        return getInstance(profileData);
    }

    public static ICC_Profile getInstance(byte[] data) {
        ICC_Profile thisProfile = null;

        long[] theID = new long[1];

        //if (ProfileDeferralMgr.deferring) {
        //    ProfileDeferralMgr.activateProfiles();
        //}

        //try {
        //    CMM.checkStatus(CMM.cmmLoadProfile(data, theID));
        //} catch (CMMException c) {
        //    throw new IllegalArgumentException("Invalid ICC Profile Data");
        //}

        //try {
            if ((getColorSpaceType(theID[0]) == ColorSpace.TYPE_GRAY)
                    && (getData(theID[0], icSigMediaWhitePointTag) != null)
                    && (getData(theID[0], icSigGrayTRCTag) != null)) {
                //thisProfile = new ICC_ProfileGray(theID[0]);
            } else if ((getColorSpaceType(theID[0]) == ColorSpace.TYPE_RGB)
                    && (getData(theID[0], icSigMediaWhitePointTag) != null)
                    && (getData(theID[0], icSigRedColorantTag) != null)
                    && (getData(theID[0], icSigGreenColorantTag) != null)
                    && (getData(theID[0], icSigBlueColorantTag) != null)
                    && (getData(theID[0], icSigRedTRCTag) != null)
                    && (getData(theID[0], icSigGreenTRCTag) != null)
                    && (getData(theID[0], icSigBlueTRCTag) != null)) {
                //thisProfile = new ICC_ProfileRGB(theID[0]);
            } else {
                thisProfile = new ICC_Profile(theID[0]);
            }
        //} catch (CMMException c) {
        //    thisProfile = new ICC_Profile(theID[0]);
        //}
        return thisProfile;
    }

    static byte[] getProfileDataFromStream(InputStream s) throws IOException {
        byte profileData[];
        int profileSize;

        byte header[] = new byte[128];
        int bytestoread = 128;
        int bytesread = 0;
        int n;

        while (bytestoread != 0) {
            if ((n = s.read(header, bytesread, bytestoread)) < 0) {
                return null;
            }
            bytesread += n;
            bytestoread -= n;
        }
        if (header[36] != 0x61 || header[37] != 0x63
                || header[38] != 0x73 || header[39] != 0x70) {
            return null;   /* not a valid profile */
        }
        profileSize = ((header[0] & 0xff) << 24)
                | ((header[1] & 0xff) << 16)
                | ((header[2] & 0xff) << 8)
                | (header[3] & 0xff);
        profileData = new byte[profileSize];
        System.arraycopy(header, 0, profileData, 0, 128);
        bytestoread = profileSize - 128;
        bytesread = 128;
        while (bytestoread != 0) {
            if ((n = s.read(profileData, bytesread, bytestoread)) < 0) {
                return null;
            }
            bytesread += n;
            bytestoread -= n;
        }

        return profileData;
    }
    transient long ID;
    //private transient ProfileDeferralInfo deferralInfo;
    //private transient ProfileActivator profileActivator;
    // Registry of singleton profile objects for specific color spaces
    // defined in the ColorSpace class (e.g. CS_sRGB), see
    // getInstance(int cspace) factory method.
    private static ICC_Profile sRGBprofile;
    private static ICC_Profile XYZprofile;
    private static ICC_Profile PYCCprofile;
    private static ICC_Profile GRAYprofile;
    private static ICC_Profile LINEAR_RGBprofile;
    /**
     * Profile class is input.
     */
    public static final int CLASS_INPUT = 0;
    /**
     * Profile class is display.
     */
    public static final int CLASS_DISPLAY = 1;
    /**
     * Profile class is output.
     */
    public static final int CLASS_OUTPUT = 2;
    /**
     * Profile class is device link.
     */
    public static final int CLASS_DEVICELINK = 3;
    /**
     * Profile class is color space conversion.
     */
    public static final int CLASS_COLORSPACECONVERSION = 4;
    /**
     * Profile class is abstract.
     */
    public static final int CLASS_ABSTRACT = 5;
    /**
     * Profile class is named color.
     */
    public static final int CLASS_NAMEDCOLOR = 6;
    /**
     * ICC Profile Color Space Type Signature: 'XYZ '.
     */
    public static final int icSigXYZData = 0x58595A20;    /* 'XYZ ' */

    /**
     * ICC Profile Color Space Type Signature: 'Lab '.
     */
    public static final int icSigLabData = 0x4C616220;    /* 'Lab ' */

    /**
     * ICC Profile Color Space Type Signature: 'Luv '.
     */
    public static final int icSigLuvData = 0x4C757620;    /* 'Luv ' */

    /**
     * ICC Profile Color Space Type Signature: 'YCbr'.
     */
    public static final int icSigYCbCrData = 0x59436272;    /* 'YCbr' */

    /**
     * ICC Profile Color Space Type Signature: 'Yxy '.
     */
    public static final int icSigYxyData = 0x59787920;    /* 'Yxy ' */

    /**
     * ICC Profile Color Space Type Signature: 'RGB '.
     */
    public static final int icSigRgbData = 0x52474220;    /* 'RGB ' */

    /**
     * ICC Profile Color Space Type Signature: 'GRAY'.
     */
    public static final int icSigGrayData = 0x47524159;    /* 'GRAY' */

    /**
     * ICC Profile Color Space Type Signature: 'HSV'.
     */
    public static final int icSigHsvData = 0x48535620;    /* 'HSV ' */

    /**
     * ICC Profile Color Space Type Signature: 'HLS'.
     */
    public static final int icSigHlsData = 0x484C5320;    /* 'HLS ' */

    /**
     * ICC Profile Color Space Type Signature: 'CMYK'.
     */
    public static final int icSigCmykData = 0x434D594B;    /* 'CMYK' */

    /**
     * ICC Profile Color Space Type Signature: 'CMY '.
     */
    public static final int icSigCmyData = 0x434D5920;    /* 'CMY ' */

    /**
     * ICC Profile Color Space Type Signature: '2CLR'.
     */
    public static final int icSigSpace2CLR = 0x32434C52;    /* '2CLR' */

    /**
     * ICC Profile Color Space Type Signature: '3CLR'.
     */
    public static final int icSigSpace3CLR = 0x33434C52;    /* '3CLR' */

    /**
     * ICC Profile Color Space Type Signature: '4CLR'.
     */
    public static final int icSigSpace4CLR = 0x34434C52;    /* '4CLR' */

    /**
     * ICC Profile Color Space Type Signature: '5CLR'.
     */
    public static final int icSigSpace5CLR = 0x35434C52;    /* '5CLR' */

    /**
     * ICC Profile Color Space Type Signature: '6CLR'.
     */
    public static final int icSigSpace6CLR = 0x36434C52;    /* '6CLR' */

    /**
     * ICC Profile Color Space Type Signature: '7CLR'.
     */
    public static final int icSigSpace7CLR = 0x37434C52;    /* '7CLR' */

    /**
     * ICC Profile Color Space Type Signature: '8CLR'.
     */
    public static final int icSigSpace8CLR = 0x38434C52;    /* '8CLR' */

    /**
     * ICC Profile Color Space Type Signature: '9CLR'.
     */
    public static final int icSigSpace9CLR = 0x39434C52;    /* '9CLR' */

    /**
     * ICC Profile Color Space Type Signature: 'ACLR'.
     */
    public static final int icSigSpaceACLR = 0x41434C52;    /* 'ACLR' */

    /**
     * ICC Profile Color Space Type Signature: 'BCLR'.
     */
    public static final int icSigSpaceBCLR = 0x42434C52;    /* 'BCLR' */

    /**
     * ICC Profile Color Space Type Signature: 'CCLR'.
     */
    public static final int icSigSpaceCCLR = 0x43434C52;    /* 'CCLR' */

    /**
     * ICC Profile Color Space Type Signature: 'DCLR'.
     */
    public static final int icSigSpaceDCLR = 0x44434C52;    /* 'DCLR' */

    /**
     * ICC Profile Color Space Type Signature: 'ECLR'.
     */
    public static final int icSigSpaceECLR = 0x45434C52;    /* 'ECLR' */

    /**
     * ICC Profile Color Space Type Signature: 'FCLR'.
     */
    public static final int icSigSpaceFCLR = 0x46434C52;    /* 'FCLR' */

    /**
     * ICC Profile Class Signature: 'scnr'.
     */
    public static final int icSigInputClass = 0x73636E72;    /* 'scnr' */

    /**
     * ICC Profile Class Signature: 'mntr'.
     */
    public static final int icSigDisplayClass = 0x6D6E7472;    /* 'mntr' */

    /**
     * ICC Profile Class Signature: 'prtr'.
     */
    public static final int icSigOutputClass = 0x70727472;    /* 'prtr' */

    /**
     * ICC Profile Class Signature: 'link'.
     */
    public static final int icSigLinkClass = 0x6C696E6B;    /* 'link' */

    /**
     * ICC Profile Class Signature: 'abst'.
     */
    public static final int icSigAbstractClass = 0x61627374;    /* 'abst' */

    /**
     * ICC Profile Class Signature: 'spac'.
     */
    public static final int icSigColorSpaceClass = 0x73706163;    /* 'spac' */

    /**
     * ICC Profile Class Signature: 'nmcl'.
     */
    public static final int icSigNamedColorClass = 0x6e6d636c;    /* 'nmcl' */

    /**
     * ICC Profile Rendering Intent: Perceptual.
     */
    public static final int icPerceptual = 0;
    /**
     * ICC Profile Rendering Intent: RelativeColorimetric.
     */
    public static final int icRelativeColorimetric = 1;
    /**
     * ICC Profile Rendering Intent: Media-RelativeColorimetric.
     * @since 1.5
     */
    public static final int icMediaRelativeColorimetric = 1;
    /**
     * ICC Profile Rendering Intent: Saturation.
     */
    public static final int icSaturation = 2;
    /**
     * ICC Profile Rendering Intent: AbsoluteColorimetric.
     */
    public static final int icAbsoluteColorimetric = 3;
    /**
     * ICC Profile Rendering Intent: ICC-AbsoluteColorimetric.
     * @since 1.5
     */
    public static final int icICCAbsoluteColorimetric = 3;
    /**
     * ICC Profile Tag Signature: 'head' - special.
     */
    public static final int icSigHead = 0x68656164; /* 'head' - special */

    /**
     * ICC Profile Tag Signature: 'A2B0'.
     */
    public static final int icSigAToB0Tag = 0x41324230;    /* 'A2B0' */

    /**
     * ICC Profile Tag Signature: 'A2B1'.
     */
    public static final int icSigAToB1Tag = 0x41324231;    /* 'A2B1' */

    /**
     * ICC Profile Tag Signature: 'A2B2'.
     */
    public static final int icSigAToB2Tag = 0x41324232;    /* 'A2B2' */

    /**
     * ICC Profile Tag Signature: 'bXYZ'.
     */
    public static final int icSigBlueColorantTag = 0x6258595A;    /* 'bXYZ' */

    /**
     * ICC Profile Tag Signature: 'bXYZ'.
     * @since 1.5
     */
    public static final int icSigBlueMatrixColumnTag = 0x6258595A; /* 'bXYZ' */

    /**
     * ICC Profile Tag Signature: 'bTRC'.
     */
    public static final int icSigBlueTRCTag = 0x62545243;    /* 'bTRC' */

    /**
     * ICC Profile Tag Signature: 'B2A0'.
     */
    public static final int icSigBToA0Tag = 0x42324130;    /* 'B2A0' */

    /**
     * ICC Profile Tag Signature: 'B2A1'.
     */
    public static final int icSigBToA1Tag = 0x42324131;    /* 'B2A1' */

    /**
     * ICC Profile Tag Signature: 'B2A2'.
     */
    public static final int icSigBToA2Tag = 0x42324132;    /* 'B2A2' */

    /**
     * ICC Profile Tag Signature: 'calt'.
     */
    public static final int icSigCalibrationDateTimeTag = 0x63616C74;
    /* 'calt' */
    /**
     * ICC Profile Tag Signature: 'targ'.
     */
    public static final int icSigCharTargetTag = 0x74617267;    /* 'targ' */

    /**
     * ICC Profile Tag Signature: 'cprt'.
     */
    public static final int icSigCopyrightTag = 0x63707274;    /* 'cprt' */

    /**
     * ICC Profile Tag Signature: 'crdi'.
     */
    public static final int icSigCrdInfoTag = 0x63726469;    /* 'crdi' */

    /**
     * ICC Profile Tag Signature: 'dmnd'.
     */
    public static final int icSigDeviceMfgDescTag = 0x646D6E64;    /* 'dmnd' */

    /**
     * ICC Profile Tag Signature: 'dmdd'.
     */
    public static final int icSigDeviceModelDescTag = 0x646D6464;  /* 'dmdd' */

    /**
     * ICC Profile Tag Signature: 'devs'.
     */
    public static final int icSigDeviceSettingsTag = 0x64657673;  /* 'devs' */

    /**
     * ICC Profile Tag Signature: 'gamt'.
     */
    public static final int icSigGamutTag = 0x67616D74;    /* 'gamt' */

    /**
     * ICC Profile Tag Signature: 'kTRC'.
     */
    public static final int icSigGrayTRCTag = 0x6b545243;    /* 'kTRC' */

    /**
     * ICC Profile Tag Signature: 'gXYZ'.
     */
    public static final int icSigGreenColorantTag = 0x6758595A;    /* 'gXYZ' */

    /**
     * ICC Profile Tag Signature: 'gXYZ'.
     * @since 1.5
     */
    public static final int icSigGreenMatrixColumnTag = 0x6758595A;/* 'gXYZ' */

    /**
     * ICC Profile Tag Signature: 'gTRC'.
     */
    public static final int icSigGreenTRCTag = 0x67545243;    /* 'gTRC' */

    /**
     * ICC Profile Tag Signature: 'lumi'.
     */
    public static final int icSigLuminanceTag = 0x6C756d69;    /* 'lumi' */

    /**
     * ICC Profile Tag Signature: 'meas'.
     */
    public static final int icSigMeasurementTag = 0x6D656173;    /* 'meas' */

    /**
     * ICC Profile Tag Signature: 'bkpt'.
     */
    public static final int icSigMediaBlackPointTag = 0x626B7074;  /* 'bkpt' */

    /**
     * ICC Profile Tag Signature: 'wtpt'.
     */
    public static final int icSigMediaWhitePointTag = 0x77747074;  /* 'wtpt' */

    /**
     * ICC Profile Tag Signature: 'ncl2'.
     */
    public static final int icSigNamedColor2Tag = 0x6E636C32;    /* 'ncl2' */

    /**
     * ICC Profile Tag Signature: 'resp'.
     */
    public static final int icSigOutputResponseTag = 0x72657370;   /* 'resp' */

    /**
     * ICC Profile Tag Signature: 'pre0'.
     */
    public static final int icSigPreview0Tag = 0x70726530;    /* 'pre0' */

    /**
     * ICC Profile Tag Signature: 'pre1'.
     */
    public static final int icSigPreview1Tag = 0x70726531;    /* 'pre1' */

    /**
     * ICC Profile Tag Signature: 'pre2'.
     */
    public static final int icSigPreview2Tag = 0x70726532;    /* 'pre2' */

    /**
     * ICC Profile Tag Signature: 'desc'.
     */
    public static final int icSigProfileDescriptionTag = 0x64657363;
    /* 'desc' */
    /**
     * ICC Profile Tag Signature: 'pseq'.
     */
    public static final int icSigProfileSequenceDescTag = 0x70736571;
    /* 'pseq' */
    /**
     * ICC Profile Tag Signature: 'psd0'.
     */
    public static final int icSigPs2CRD0Tag = 0x70736430;    /* 'psd0' */

    /**
     * ICC Profile Tag Signature: 'psd1'.
     */
    public static final int icSigPs2CRD1Tag = 0x70736431;    /* 'psd1' */

    /**
     * ICC Profile Tag Signature: 'psd2'.
     */
    public static final int icSigPs2CRD2Tag = 0x70736432;    /* 'psd2' */

    /**
     * ICC Profile Tag Signature: 'psd3'.
     */
    public static final int icSigPs2CRD3Tag = 0x70736433;    /* 'psd3' */

    /**
     * ICC Profile Tag Signature: 'ps2s'.
     */
    public static final int icSigPs2CSATag = 0x70733273;    /* 'ps2s' */

    /**
     * ICC Profile Tag Signature: 'ps2i'.
     */
    public static final int icSigPs2RenderingIntentTag = 0x70733269;
    /* 'ps2i' */
    /**
     * ICC Profile Tag Signature: 'rXYZ'.
     */
    public static final int icSigRedColorantTag = 0x7258595A;    /* 'rXYZ' */

    /**
     * ICC Profile Tag Signature: 'rXYZ'.
     * @since 1.5
     */
    public static final int icSigRedMatrixColumnTag = 0x7258595A;  /* 'rXYZ' */

    /**
     * ICC Profile Tag Signature: 'rTRC'.
     */
    public static final int icSigRedTRCTag = 0x72545243;    /* 'rTRC' */

    /**
     * ICC Profile Tag Signature: 'scrd'.
     */
    public static final int icSigScreeningDescTag = 0x73637264;    /* 'scrd' */

    /**
     * ICC Profile Tag Signature: 'scrn'.
     */
    public static final int icSigScreeningTag = 0x7363726E;    /* 'scrn' */

    /**
     * ICC Profile Tag Signature: 'tech'.
     */
    public static final int icSigTechnologyTag = 0x74656368;    /* 'tech' */

    /**
     * ICC Profile Tag Signature: 'bfd '.
     */
    public static final int icSigUcrBgTag = 0x62666420;    /* 'bfd ' */

    /**
     * ICC Profile Tag Signature: 'vued'.
     */
    public static final int icSigViewingCondDescTag = 0x76756564;  /* 'vued' */

    /**
     * ICC Profile Tag Signature: 'view'.
     */
    public static final int icSigViewingConditionsTag = 0x76696577;/* 'view' */

    /**
     * ICC Profile Tag Signature: 'chrm'.
     */
    public static final int icSigChromaticityTag = 0x6368726d;    /* 'chrm' */

    /**
     * ICC Profile Tag Signature: 'chad'.
     * @since 1.5
     */
    public static final int icSigChromaticAdaptationTag = 0x63686164;/* 'chad' */

    /**
     * ICC Profile Tag Signature: 'clro'.
     * @since 1.5
     */
    public static final int icSigColorantOrderTag = 0x636C726F;    /* 'clro' */

    /**
     * ICC Profile Tag Signature: 'clrt'.
     * @since 1.5
     */
    public static final int icSigColorantTableTag = 0x636C7274;    /* 'clrt' */

    /**
     * ICC Profile Header Location: profile size in bytes.
     */
    public static final int icHdrSize = 0;  /* Profile size in bytes */

    /**
     * ICC Profile Header Location: CMM for this profile.
     */
    public static final int icHdrCmmId = 4;  /* CMM for this profile */

    /**
     * ICC Profile Header Location: format version number.
     */
    public static final int icHdrVersion = 8;  /* Format version number */

    /**
     * ICC Profile Header Location: type of profile.
     */
    public static final int icHdrDeviceClass = 12; /* Type of profile */

    /**
     * ICC Profile Header Location: color space of data.
     */
    public static final int icHdrColorSpace = 16; /* Color space of data */

    /**
     * ICC Profile Header Location: PCS - XYZ or Lab only.
     */
    public static final int icHdrPcs = 20; /* PCS - XYZ or Lab only */

    /**
     * ICC Profile Header Location: date profile was created.
     */
    public static final int icHdrDate = 24; /* Date profile was created */

    /**
     * ICC Profile Header Location: icMagicNumber.
     */
    public static final int icHdrMagic = 36; /* icMagicNumber */

    /**
     * ICC Profile Header Location: primary platform.
     */
    public static final int icHdrPlatform = 40; /* Primary Platform */

    /**
     * ICC Profile Header Location: various bit settings.
     */
    public static final int icHdrFlags = 44; /* Various bit settings */

    /**
     * ICC Profile Header Location: device manufacturer.
     */
    public static final int icHdrManufacturer = 48; /* Device manufacturer */

    /**
     * ICC Profile Header Location: device model number.
     */
    public static final int icHdrModel = 52; /* Device model number */

    /**
     * ICC Profile Header Location: device attributes.
     */
    public static final int icHdrAttributes = 56; /* Device attributes */

    /**
     * ICC Profile Header Location: rendering intent.
     */
    public static final int icHdrRenderingIntent = 64; /* Rendering intent */

    /**
     * ICC Profile Header Location: profile illuminant.
     */
    public static final int icHdrIlluminant = 68; /* Profile illuminant */

    /**
     * ICC Profile Header Location: profile creator.
     */
    public static final int icHdrCreator = 80; /* Profile creator */

    /**
     * ICC Profile Header Location: profile's ID.
     * @since 1.5
     */
    public static final int icHdrProfileID = 84; /* Profile's ID */

    /**
     * ICC Profile Constant: tag type signaturE.
     */
    public static final int icTagType = 0;    /* tag type signature */

    /**
     * ICC Profile Constant: reserved.
     */
    public static final int icTagReserved = 4;    /* reserved */

    /**
     * ICC Profile Constant: curveType count.
     */
    public static final int icCurveCount = 8;    /* curveType count */

    /**
     * ICC Profile Constant: curveType data.
     */
    public static final int icCurveData = 12;   /* curveType data */

    /**
     * ICC Profile Constant: XYZNumber X.
     */
    public static final int icXYZNumberX = 8;    /* XYZNumber X */

}
